﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Server
{
    public partial class frmSet : Form
    {
        public frmSet()
        {
            InitializeComponent();
        }

        /// <summary>
        /// LODE
        /// </summary>
        private void frmSet_Load(object sender, EventArgs e)
        {
            txtIp.Text = BaseClass.ServerIp;
            txtProt.Text = BaseClass.ServerPort.ToString();
        }


        /// <summary>
        /// 设置IP和端口
        /// </summary>
        private void btnSeting_Click(object sender, EventArgs e)
        {
            if (BaseClass.ServerConnt)
            {
                MessageBox.Show("服务器启动状态不能修改IP或端口，请断开后再试！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            ReaderWriter.WriteIni("config", "server", "ip", txtIp.Text.Trim());
            ReaderWriter.WriteIni("config", "server", "port", txtProt.Text.Trim());
            BaseClass.ServerIp = txtIp.Text.Trim();
            BaseClass.ServerPort = int.Parse(txtProt.Text.Trim());
            MessageBox.Show("设置成功！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            this.Close();
        }

    }
}
